<template>
	<hx-navbar :is-back="false" :title="pageDesign.pageName"></hx-navbar>
	<view v-for="(item, index) in pageDesign.pageContent.componentsList" :key="index">
		<diy-notice v-if="item.name == 'notice'" :showData="item.data"></diy-notice>
		<diy-goods v-if="item.name == 'goods'" :showData="item.data"></diy-goods>
		<diy-tabnav v-if="item.name == 'tabNav'" :showData="item.data"></diy-tabnav>
		<diy-image v-if="item.name == 'image'" :showData="item.data"></diy-image>
		<diy-title-text v-if="item.name == 'titleText'" :showData="item.data"></diy-title-text>
	</view>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { onLoad, onPullDownRefresh } from '@dcloudio/uni-app';
import DiyNotice from '@/components/diy-page/diy-notice/index.vue';
import DiyGoods from '@/components/diy-page/diy-goods/index.vue';
import DiyTabnav from '@/components/diy-page/diy-tabnav/index.vue';
import DiyImage from '@/components/diy-page/diy-image/index.vue';
import DiyTitleText from '@/components/diy-page/diy-titletext/index.vue';
import { useTabBarStore } from '@/stores/tabBar';
import { getPageDesign } from '@/api/shop/pageDesign';
const pageDesign = ref<{ pageName: string; pageContent: any }>({
	pageName: '首页',
	pageContent: {
		componentsList: [],
	},
});

const initPageDesign = () => {
	getPageDesign({}).then((response) => {
		pageDesign.value = response.data;
		uni.stopPullDownRefresh();
	});
};
onLoad(() => {
	initPageDesign();
	useTabBarStore().initTabBar();
});
onPullDownRefresh(() => {
	initPageDesign();
});
</script>

<style></style>
